package cc.code.shapp.Main;

import cc.code.shapp.utils.ClickScreenUtil;
import cc.code.shapp.utils.ScreenCaptureUtil;

import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;

public class Main {

    static String addMoneyTime;
    static String addMoneyNum;
    static String submitTime;

    static int jiajia_x;
    static int jiajia_y;
    static int chujia_x;
    static int chujia_y;
    static int submit_x;
    static int submit_y;

    static int x1;
    static int y1;
    static int x2;
    static int y2;

    static SimpleDateFormat sdf = new SimpleDateFormat("HHmmss");

    static {
        try {
            getCfg();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws IOException, InterruptedException {
        String now;
        while(true) {
            Thread.sleep(1000);
            now = sdf.format(new Date());
            if(addMoneyTime.equals(now)) {
                System.out.println(now);
                ClickScreenUtil.clickScreenByXY(jiajia_x, jiajia_y);
                ClickScreenUtil.clickScreenByXY(chujia_x, chujia_y);
            }
            if(submitTime.equals(now)) {
                System.out.println(now);
                ClickScreenUtil.clickScreenByXY(submit_x, submit_y);
            }

        }




    }

    public static void getCfg() throws IOException {
        String location = "cfg.properties";
        InputStream input = Main.class.getClassLoader().getResourceAsStream(location);
        Properties properties = new Properties();
        properties.load(input);
        addMoneyTime = properties.getProperty("addMoneyTime");
        addMoneyNum = properties.getProperty("addMoneyTime");
        submitTime = properties.getProperty("addMoneyTime");
        jiajia_x = Integer.parseInt(properties.getProperty("jiajia_x"));
        jiajia_y = Integer.parseInt(properties.getProperty("jiajia_y"));
        chujia_x = Integer.parseInt(properties.getProperty("chujia_x"));
        chujia_y = Integer.parseInt(properties.getProperty("chujia_y"));
        submit_x = Integer.parseInt(properties.getProperty("submit_x"));
        x1 = Integer.parseInt(properties.getProperty("x1"));
        y1 = Integer.parseInt(properties.getProperty("x2"));
        x2 = Integer.parseInt(properties.getProperty("y1"));
        y2 = Integer.parseInt(properties.getProperty("y2"));
    }

}
